package com.xiaoshuidi.cloud.module.rooms.controller.admin.equipmentStocktaking;


import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.equipmentStocktaking.vo.EquipmentStocktakingCreateReqVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.equipmentStocktaking.vo.EquipmentStocktakingPageReqVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.equipmentStocktaking.vo.EquipmentStocktakingPageResp;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.service.IEquipmentStocktakingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

/**
 * 资产管理-盘点管理
 *
 * @author Link
 * @since 2023-05-21
 */
@Tag(name = "管理后台 - 盘点管理")
@RestController
@RequestMapping(ApiConstants.NAME + "/equipmentStocktaking")
@RequiredArgsConstructor
public class EquipmentStocktakingController {

    @Resource
    private IEquipmentStocktakingService iEquipmentStocktakingService;

    /**
     * 新增盘点单
     **/
    @PostMapping("/create")
    @Operation(summary = "新增盘点单")
    @PreAuthorize("@ss.hasAnyPermissions('rooms:equipment:stocktaking:create')")
    public CommonResult<Long> create(@RequestBody EquipmentStocktakingCreateReqVO createReqVO) {
        Long id = iEquipmentStocktakingService.createEquipmentStocktakingList(createReqVO);
        return success(id);
    }

    /**
     * 盘点单-分页查询
     */
    @Operation(summary = "盘点单-分页查询", description = "根据权限，传入门店id")
    @GetMapping("/pageQuery")
    @PreAuthorize("@ss.hasAnyPermissions('rooms:equipment:stocktaking:query')")
    public CommonResult<PageResult<EquipmentStocktakingPageResp>> getEquipmentStocktakingPage(@Valid EquipmentStocktakingPageReqVO reqVO) {
        PageResult<EquipmentStocktakingPageResp> page = iEquipmentStocktakingService.getEquipmentStocktakingPage(reqVO);
        return success(page);
    }

}
